package com.yuanqi.Service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanqi.Common.Expriess.BaseException;
import com.yuanqi.Mapper.UpdateMapper;
import com.yuanqi.Common.Pojo.entity.Update;
import com.yuanqi.Service.UpdateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UpdateServiceImpl extends ServiceImpl<UpdateMapper, Update> implements UpdateService {
    @Resource
    UpdateMapper updateMapper;
    @Override
    public Update check(Update update) {
        Update update1 = updateMapper.selectOne(new LambdaQueryWrapper<Update>().eq(Update::getStatus, 1));
        if (update1==null)
        {
            throw  new BaseException("暂时没有更新");
        }
        if (update1.getVersion().equals(update.getVersion()))
        {
            throw new BaseException("已经是最新版本");
        }
        return update1;
    }
}
